<include file="Public/min-header"/>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-list"></i> 秒杀商品详情</h3>
                    </div>
                    <div class="panel-body">
                        
                        <div class="navbar navbar-default">
                            <div>
                                商品秒杀详情：{$gggg.goods_name}　　　　售价：{$gggg.shop_price}
                            </div class="pull-left">
                            <div class="pull-right" style="margin-right: 10px">
                                <a href="javascript:history.go(-1)" data-toggle="tooltip" title=""
                                   class="btn btn-default"
                                   data-original-title="返回"><i class="fa fa-reply"></i></a>
                            </div>
                        </div>
                        <form action="{:U('Miaosha/info_miaosha_goods')}" id="search-form2" class="navbar-form form-inline" method="get">
                            <div class="form-group">
                                <label class="control-label" for="input-date-added">日期查找</label>
                                <div class="input-group">
                                    <input type="date" name="first_time" value="{$first_time}" placeholder="开始日期"  id="add_time" class="input-sm">~
                                    <input type="date" name="last_time" value="{$last_time}" placeholder="结束日期"  id="add_time" class="input-sm">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <button 
                                    type="submit"
                                   id="button-filter search-order"
                                   class="btn btn-primary">
                                    <i class="fa fa-search"></i> 筛选</button>
                            </div>
                            <input type="hidden" name="goods_id" value="{$gggg.goods_id}">
                        </form>
                        <div id="ajax_return">
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                    <!-- <?php echo '<pre>';var_dump($list['attr']); ?> -->
                                        <td class="text-center">规格</td>
                                        <td class="text-center">日期</td>
                                        <td class="text-center">时间</td>
                                        <td class="text-center">限购数量</td>
                                        <td class="text-center">限购单数</td>
                                        <td class="text-center">秒杀价</td>
                                        <td class="text-center">数量</td>
                                        <td class="text-center"></td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                        <volist name="ms_goods" id="list">

                                            <tr>
                                                <td class="text-center">默认</td>
                                                <td class="text-center">{$list['open_time']}</td>
                                                <td class="text-center">{$list['start_time']}:00~{$list['start_time']}:59</td>
                                                <td class="text-center">{$list['buy_max']}</td>
                                                <td class="text-center">{$list['buy_limit']}</td>
                                                <td class="text-center">
                                                    <input  type="number"
                                                            item='0.01'
                                                            name="ms_price"
                                                            ids = "{$list['id']}"
                                                           class="form-control form-control-sm check-goods-data"
                                                            value="{$list['ms_price']}"
                                                           step="0.01" min="0.01"
                                                           max="{$gggg['shop_price']}" 
                                                           style = "width:100px;"
                                                           >
                                                </td>
                                                <td class="text-center">
                                                    <input  type="number"
                                                            name="ms_num"
                                                            ids = "{$list['id']}"
                                                            class="form-control form-control-sm check-goods-data"
                                                            value="{$list['ms_num']}"
                                                            step="1" min="1"
                                                            max="{$gggg['store_count']}"
                                                            style = "width:100px;"
                                                    />
                                                </td>
                                                <td class="text-center">
                                                    
                                                    <a data-url="{:U('Miaosha/del_ms_goods_one',array('id'=>$list['id']))}"
                                                       onclick="delfun(this)" href="javascript:;" data-toggle="tooltip"
                                                       title="" class="btn btn-danger" data-original-title="删除"><i
                                                            class="fa fa-trash-o"></i></a>

                                                </td>
                                            </tr>
                                        </volist>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6 text-left"></div>
                            <div class="col-sm-6 text-right">{$page}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<script>

    /**
     * 秒杀价
     */
    $('input[name="ms_price"]').blur(function () {
        var ms_price = $(this).val()
        var id = $(this).attr('ids');
        // ms_price = floatval(ms_price);
        // console.log(id);
        // console.log(typeof(ms_price));
        $.post('{:U("Miaosha/ajax_goodsprice_one")}',{id:id,ms_price:ms_price,},function (e) {
            console.log(e);
            if(e.status){
                layer.alert(e.msg, {icon: 1});

            }else{
                layer.alert(e.msg, {icon: 2});
            }
        })
    });
    /**
     * 秒杀数量
     */
    $('input[name="ms_num"]').blur(function () {
        var ms_num =parseInt($(this).val())
        var id = $(this).attr('ids');
        // console.log(typeof(ms_num));
        $.post('{:U("Miaosha/ajax_goodsnum_one")}',{id:id,ms_num:ms_num,},function (e) {
            console.log(e);
            if(e.status){
                layer.alert(e.msg, {icon: 1});
            }else{
                layer.alert(e.msg, {icon: 2});
            }
        })
    })

    function delfun(obj) {
        if (confirm('确认删除')) {
            $.ajax({
                type: 'post',
                url: $(obj).attr('data-url'),
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    if (data) {
                        $(obj).parent().parent().remove();
                    } else {
                        layer.alert('删除失败', {icon: 2});  //alert('删除失败');
                    }
                }
            })
        }
        return false;
    }
</script>
</body>
</html>